package com.justgame.project.cloud.common.config;

import com.aliyun.oss.ClientBuilderConfiguration;
import com.aliyun.oss.OSS;
import com.aliyun.oss.OSSClientBuilder;
import com.justgame.project.cloud.common.util.AliyunOssUtil;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * oss对象存储
 */
@Configuration
public class OssConfig {

    @Bean
    public OSS oss() {
        ClientBuilderConfiguration conf = new ClientBuilderConfiguration();
        conf.setSupportCname(true);
        return new OSSClientBuilder().build(
                AliyunOssUtil.getEndpoint(),
                AliyunOssUtil.getKeyId(),
                AliyunOssUtil.getSecret(),
                conf
        );
    }
}
